<style>
.rules{ float:left; margin-left:10px;}
</style>
<div class="page-content" >
	<div class="panel panel-default">
		<div class="panel-heading">
				<ul class="breadcrumb">
                    <li><a href="<{:U('index')}>">管理员</a> </li>
                    <li class="active">分配权限</li>
                </ul>
		 </div>
		<div class="panel-body">
			<form id="myform" method="post" class="form-horizontal" action="<{:U('access_add_do')}>">
                    <input name="ids" type="hidden" />
					 <input name="group_ids" type="hidden" />
					  <input name="group_ids_val" type="hidden" />
                    <input name="admin_id" type="hidden" value="<{$_GET['admin_id']}>" />
                    	 
                        <volist name="data" id="vo">
                            <div class="vmall_cle">
                                <label for="input-title" class="vmall_te_le" style="color:#0080FF">
                                    <label>  <input type="checkbox" name="group_id[]" attr="<{$vo.id}>" value="<{$vo.rid}>" <{$vo.checked}>  />
                                     <{$vo.title}></label>
                                </label>
                                <div class="form-group">
                                    <volist name="vo.rule" id="rule">
                                     <div class="rules">
                                      <span>
                                       <label> <input type="checkbox" disabled="disabled"  name="rules_id[]" value="<{$rule.id}>" <{$rule.checked}>><{$rule.title}></label>
                                       </span>  
                                     </div>
                                    </volist>
                                </div>
                            </div>
                        </volist>
							
                             
<div class="form-group">
					<div class="col-sm-offset-2 col-sm-7">
						<button type="submit" class="btn btn-primary">保存</button>
						<button type="button" onclick="javascript:history.go(-1);" class="btn btn-primary">返回</button>
					</div>
				</div>
                         
                     </form>
			
			<div class="clearfix"></div>
		</div>
	</div>
</div>

 <script type="text/javascript">
    $(function(){
        $('input[name="group_id[]"]').click(function(){
            if($(this).prop('checked')){
                $(this).parents('.vmall_cle').find('input[name="rules_id[]"]').removeAttr('disabled');
				$(this).parents('.vmall_cle').find('input[name="rules_id[]"]').prop('checked','checked');
            }else{
                $(this).parents('.vmall_cle').find('input[name="rules_id[]"]').attr('disabled','disabled').removeAttr('checked');
            }
        })
        $("#myform").submit(function(){
            var _group_id=new Array();
            var _rules_id=new Array();
			var group_ids_val=new Array();
            $('input[name="group_id[]"]:checked').each(function(i){
                _group_id.push($(this).val());
				 group_ids_val.push($(this).attr("attr"));
            })
            $('input[name="rules_id[]"]:checked').each(function(i){
                _rules_id.push($(this).val());
            })
            var ids=_group_id+','+_rules_id;
			//console.log(_group_id);
			//console.log(group_ids_val);
			//return false;
            $('input[name="ids"]').val(ids);
			$('input[name="group_ids"]').val(_group_id);
			$('input[name="group_ids_val"]').val(group_ids_val);
		
        })
        $('input[name="group_id[]"]:checked').each(function(i){
            $(this).parents('.vmall_cle').find('input[name="rules_id[]"]').removeAttr('disabled');
        })
    })
</script>
 